package com.itheima.consumer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutConfig {

    /**
     * 声明交换机
     * @return
     */
    @Bean
    public FanoutExchange fanoutExchange(){
        //return ExchangeBuilder.fanoutExchange("fanoutExchange").build();
        return new FanoutExchange("fanout2Exchange");
    }

    /**
     * 声明队列
     * @return
     */
    @Bean
    public Queue fanoutQueue1(){
        return new Queue("fanoutQueue1");
    }

    /**
     * 绑定队列和交换机
     * @return
     */
    @Bean
    public Binding binding1(){
        return BindingBuilder.bind(fanoutQueue1()).to(fanoutExchange());
    }
}
